-module(exit_handler).
-compile(export_all).

child() ->
	receive
		{convert, T} ->
			list_to_atom(T)
	end.
	
parent(ChildPid) ->
	process_flag(trap_exit, true),
	link(ChildPid),
	receive
		{'EXIT', Pid, Why} ->
			io:fwrite("~p died with ~p~n", [Pid, Why])
	end.

start() ->
	ChildPid = spawn(fun() -> child() end),
	spawn(fun() -> parent(ChildPid) end),
	ChildPid ! {convert, hello},
	ok.